﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Compact13TaskManager
{

    public partial class frmMain : Form
    {
        public bool IsAlphaNumeric(string stringValue)
        {
            //Apps can have <appname> : <doc name>
            int index = stringValue.IndexOf(':');
            if (index != -1)
                stringValue = stringValue.Substring(0, index );

            //Allow - and _ and spaceas well
            stringValue = stringValue.Replace("_", "");
            stringValue = stringValue.Replace("-", "");
            stringValue = stringValue.Replace(" ", "");
            stringValue = stringValue.Replace(".", "");
            bool m_result = true;

            string m_strValue = stringValue.Trim();



            System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9]*$");

            if (!rx.IsMatch(m_strValue))
            {

                m_result = false;

            }

            return m_result;

        }

        public bool IsNumeric(string stringValue)
        {
            //Aloow - and _ as well
            stringValue = stringValue.Replace("_", "");
            stringValue = stringValue.Replace("-", "");
            bool m_result = true;

            string m_strValue = stringValue.Trim();



            System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(@"^[0-9]*$");

            if (!rx.IsMatch(m_strValue))
            {

                m_result = false;

            }

            return m_result;

        }

        public bool IsAlpha(string stringValue)
        {
            //Aloow - and _ as well
            stringValue = stringValue.Replace("_", "");
            stringValue = stringValue.Replace("-", "");
            bool m_result = true;

            string m_strValue = stringValue.Trim();



            System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z]*$");

            if (!rx.IsMatch(m_strValue))
            {

                m_result = false;

            }

            return m_result;

        }

    }
}
